<template>
  <div class="message-dialog">
    <el-dialog :before-close="handleCancel" :visible.sync="dialog" title="添加机构">
      <el-form :model="form" label-width="100px">
        <el-form-item label="选择文件">
          <el-upload
            ref="uploadaaaa"
            :auto-upload="false"
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
          >
            <el-input slot="trigger" v-model="form.url" style="width:400px">
              <el-button slot="append" :style="innerButton">选取文件</el-button>
            </el-input>
            <p slot="tip" style="color:#7a7a7a;margin:0">
              支持从Excel文件导入 &nbsp;
              <a style="color:red;">点击下载示例说明文件</a>
            </p>
          </el-upload>
        </el-form-item>
        <el-form-item label="购买价格">
          <el-input v-model="form.price" style="width:380px"/>&nbsp;元
          <p style="margin:0">本课程的价格为{{ form.price }}元</p>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="form.remark" style="width:400px"/>
          <p style="margin:0">选填</p>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleCancel">取 消</el-button>
        <el-button type="primary" @click="handlePush">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    visibleDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {
        url: 'https://jsonplaceholder.typicode.com/posts/',
        price: '1',
        remark: ''
      },
      innerButton: {
        backgroundColor: '#409EFF',
        border: '1px solid #409EFF',
        color: '#fff'
      }
    }
  },
  computed: {
    dialog() {
      return this.visibleDialog
    }
  },
  methods: {
    handlePush() {
      this.$refs.uploadaaaa.submit()
      this.$emit('closeAddMore')
    },
    handleCancel() {
      this.$emit('closeAddMore')
    }
  }
}
</script>

<style lang="scss">
.message-dialog {
  .el-dialog {
    width: 600px;
    border-radius: 5px;
  }
}
</style>
